package com.shruijin.wy.property.config;

import com.shruijin.wy.property.common.rpc.RpcResultHandler;
import com.shruijin.wy.uc.sdk.auth.UCAuthInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created by enzo on 2018/5/22.
 */
@Configuration
public  class WebAppConfig implements WebMvcConfigurer {

    @Autowired
    UCAuthInterceptor ucAuthInterceptor;

    @Autowired
    RpcResultHandler rpcResultHandler;

    @Bean
    public UCAuthInterceptor ucAuthInterceptorRegistery(){
        UCAuthInterceptor ucAuthInterceptor = new UCAuthInterceptor();
        return ucAuthInterceptor;
    }

    @Bean
    public RpcResultHandler rpcResultHandlerRegistery(){
        RpcResultHandler rpcResultHandler = new RpcResultHandler();
        return rpcResultHandler;
    }

    @Override
    public void  addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(ucAuthInterceptor).addPathPatterns("/test/**");
    }
}
